# Makefile

SHELL=/bin/bash
CC=gcc
SRCS=principal.c lista.c josephus.c
OBJS=principal.o lista.o josephus.o
CFLAGS=-std=c99 -pedantic -Wall -ggdb
PROGRAM=./principal

.PHONY: depend clean

$(PROGRAM): $(SRCS) $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o principal

$(OBJS): %.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

test: $(PROGRAM)
	@for arqin in arq*.in; do \
	   if ! $(PROGRAM) < $${arqin} > $${arqin%.in}.out; then \
	      echo ":-( teste $${arqin} falhou."; \
	   else \
	      if diff $${arqin%.in}.out $${arqin%.in}.res; then \
	         echo ":-) teste $${arqin} passou"; \
	      else \
	         echo ":-( teste $${arqin} falhou."; \
	      fi \
	   fi \
	done

depend:
	makedepend -Y $(SRCS) 2>/dev/null

clean:
	-rm -f $(OBJS) $(PROGRAM) *.out


# DO NOT DELETE

principal.o: lista.h josephus.h
lista.o: lista.h josephus.h
josephus.o: josephus.h
